﻿using Newtonsoft.Json;
using OSSUtility;
using Ozone.Device;
using Ozone.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Models
{

    public class MethodMain
    {
        public List<Method> ListMethod { set; get; }

        public MethodMain()
        {
            ListMethod = new List<Method>();
        }

    }

    public class Method
    {

        public string FID { set; get; }
        public string FName { set; get; }

        public List<MethodItem> ListMethodItem { set; get; }

        public Method()
        {
            ListMethodItem = new List<MethodItem>();
        }

        public void SortMethodItem()
        {

        }


        /// <summary>
        /// 状态重置
        /// </summary>
        public void ResetStatus(int ndgMethodItemIndex)
        {
            for (int i = 0; i < ListMethodItem.Count; i++)
            {
                if (ndgMethodItemIndex == i)
                {
                    ListMethodItem[i].FStatus = 0;
                }
            }
        }
    }

    //方法配置
    public class MethodItem
    {

        public int FNO { set; get; }


        /*运行状态 0：未运行 
         *         1：等待中
         *         2：执行中
         *         3：保持中
         *         4：已完成 
         */
        [JsonIgnore]
        public int FStatus { set; get; }
        public string FStatusStr
        {
            get
            {
                if (FStatus == 0) return "未执行";
                if (FStatus == 1) return "配液中";
                if (FStatus == 2) return "配液完成";
                if (FStatus == 3) return "插管完成";
                if (FStatus == 4) return "磁力加热搅拌中";
                if (FStatus == 5) return "加热搅拌完成";
                if (FStatus == 6) return "反应器反应完成";
                if (FStatus == 7) return "馏分收集中";
                if (FStatus == 8) return "馏分收集完成";
                if (FStatus == 9) return "试管搬运中";
                if (FStatus == 10) return "试管搬运完成";
                if (FStatus == 11) return "AGV小车运行至三工位";
                if (FStatus == 12) return "试管架放置完成";
                if (FStatus == 13) return "三工位工作完成";
                if (FStatus == 14) return "离心管装填完成";
                if (FStatus == 15) return "离心完成";
                if (FStatus == 16) return "离心管拆卸完成";
                if (FStatus == 17) return "补液完成";
                if (FStatus == 18) return "超声完成";
                if (FStatus == 19) return "开始旋蒸";
                if (FStatus == 20) return "旋蒸完成";
                if (FStatus == 21) return "旋蒸瓶补液完成";
                if (FStatus == 22) return "执行完成";
                if (FStatus == 23) return "执行停止";
                if (FStatus == 100) return "反应最终收集产物完成";
                if (FStatus == 111) return "离心全流程失败";
                if (FStatus == 222) return "离心全流程失败";
                if (FStatus == -1) return "执行失败";
                return "";
            }
        }
        /// <summary>
        /// 配液方法名称
        /// </summary>
        public string DispensingMethodName { get; set; }
        /// <summary>
        /// 磁力加热温度
        /// </summary>
        public int IKATemp { get; set; }

        /// <summary>
        /// 磁力搅拌转速
        /// </summary>
        public int IKASpeed { get; set; }

        /// <summary>
        /// 加热时间
        /// </summary>
        public int IKATempTime { get; set; }
        /// <summary>
        /// 搅拌时间
        /// </summary>
        public int IKASpeedTime { get; set; }


        /// <summary>
        /// 馏分开始试管
        /// </summary>
        public int Fristtesttube { get; set; }

        /// <summary>
        /// 馏分结束试管
        /// </summary>

        public int Endtesttube { set; get; }

        /// <summary>
        /// 馏分容量
        /// </summary>
        public int LFCapacity { set; get; }


        /// <summary>
        /// 离心机速度
        /// </summary>
        public int CentrifugeSpeed { get; set; }


        /// <summary>
        /// 离心时间
        /// </summary>
        public int CentrifugeTime { get; set; }

        /// <summary>
        /// 离心机温度
        /// </summary>
        public int CentrifugeTemperature { get; set; }




        /// <summary>
        /// 离心机速度
        /// </summary>
        public int CentrifugeSpeedTwo { get; set; }


        /// <summary>
        /// 离心时间
        /// </summary>
        public int CentrifugeTimeTwo { get; set; }

        /// <summary>
        /// 离心机温度
        /// </summary>
        public int CentrifugeTemperatureTwo { get; set; }


        /// <summary>
        /// 流量计1流速
        /// </summary>
        public int Flow1 { get; set; }


        /// <summary>
        /// 流量计2流速
        /// </summary>
        public int Flow2 { get; set; }



        /// <summary>
        /// 超声功率
        /// </summary>
        public string ultrasoundPower { get; set; }


        /// <summary>
        /// 超声试管时间
        /// </summary>
        public int ultrasoundTime { get; set; }

        /// <summary>
        /// 超声旋蒸瓶时间
        /// </summary>

        public int ultrasoundXZTime { get; set; }


        /// <summary>
        /// 旋蒸温度
        /// </summary>
        public int RotaryTemp { get; set; }

        /// <summary>
        /// 旋蒸旋转速度
        /// </summary>
        public int RotarySpeed { get; set; }

        /// <summary>
        /// 旋蒸压强
        /// </summary>
        public int RotaryPa { get; set; }

        /// <summary>
        /// 旋蒸时间
        /// </summary>
        public int RotaryTime { get; set; }


        /// <summary>
        /// 柱塞泵 流速  进馏分使用
        /// </summary>
        public string OsskjPumpfolw { get; set; }

        /// <summary>
        /// 泵启动间隔时间   主要解决 两个泵进反应器由于管路和盘管不一样导致 一前一后 需要等待
        /// </summary>
        public string PumpintervalTime { get; set; }

        /// <summary>
        /// 板式反应器温度1 
        /// </summary>
        public string BSReactorHeat1 { get; set; }

        /// <summary>
        ///  板式反应器温度2
        /// </summary>
        public string BSReactorHeat2 { get; set; }

        /// <summary>
        /// 管式反应器温度
        /// </summary>
        public string GSReactorHeat { get; set; }

        /// <summary>
        /// 加热泵流速
        /// </summary>
        public string HeatPumpFlow { get; set; }

        /// <summary>
        /// 加热泵通道1温度
        /// </summary>
        public string HeatPump1 { get; set; }


        /// <summary>
        /// 加热泵通道2温度
        /// </summary>
        public string HeatPump2 { get; set; }


        /// <summary>
        /// 加热泵通道3温度
        /// </summary>
        public string HeatPump3 { get; set; }

        /// <summary>
        /// 加热泵通道4温度
        /// </summary>
        public string HeatPump4 { get; set; }

        /// <summary>
        /// 三工位补液1
        /// </summary>
        public string ThreeWorkBY1 { get; set; }

        /// <summary>
        /// 三工位补液2
        /// </summary>
        public string ThreeWorkBY2 { get; set; }

        /// <summary>
        /// 三工位补液3
        /// </summary>
        public string ThreeWorkBY3 { get; set; }


        /// <summary>
        /// 旋蒸柱塞泵流速
        /// </summary>
        public string XZOsskjPumpFlow { get; set; }

        /// <summary>
        /// 旋蒸柱塞泵补液体积
        /// </summary>
        public string XZOsskjPumpVolume { get; set; }

        /// <summary>
        /// 馏分试管列表
        /// </summary>
        public List<Testtube> ListTesttube { set; get; } = new List<Testtube>();
    }


    public class Testtube
    {
        /// <summary>
        /// 试管编号
        /// </summary>
        public int TesttubeNo { get; set; }
        /// <summary>
        /// 试管容量
        /// </summary>
        public int Capacity { get; set; }
        /*收集状态 0：未收集
        *         1：收集中
        *         2：收集完成
        */
        public int State { get; set; }



    }
}
